package com.tron.auth.service;

import com.tron.auth.entity.MyUserRoles;
import com.tron.auth.entity.MyUserDetails;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.HashSet;

/**
 * 根据用户从数据库获取用户信息
 * @author : TRON
 * @since  : 2019-09-16 16:08
 */

@Service
public class MyUserDetailsService implements UserDetailsService {

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        //这里返回的用户应该从数据库获取
        HashSet<MyUserRoles> myRoles = new HashSet<>();
        myRoles.add(new MyUserRoles("USER"));
        MyUserDetails myUserDetails = new MyUserDetails("user", "123456","真武幻", myRoles);
        return myUserDetails;
    }
}
